package com.zhf.infrastructure.generator;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.nio.file.Paths;

/**
 * @author zhouhaofeng
 * @description
 * @date 2025/7/17 17:15
 * @verson 1.0
 * @changelog --
 * - 2025/7/17 1.0 - new class
 */
public class CodeGenerator {

    public static void main(String[] args) {

        String url = "jdbc:mysql://47.119.180.252:13306/big_market?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&serverTimezone=UTC&useSSL=true";
        String username = "root";
        String password = "123456";

        String modulePath = "/big-market-hf-infrastructure";

        FastAutoGenerator.create(url, username, password)
                .globalConfig(builder -> builder
                        .author("zhouhaofeng")
                        .outputDir(Paths.get(System.getProperty("user.dir")) + modulePath + "/src/main/java")
                        .commentDate("yyyy-MM-dd")
                )
                .packageConfig(builder -> builder
                        .parent("com.zhf.infrastructure.generator")
                        .entity("entity")
                        .mapper("mapper")
                        .service("service")
                        .serviceImpl("service.impl")
                        .xml("mapper.xml")
                )
                .strategyConfig(builder -> builder
                        .entityBuilder()
                        .enableLombok()
                )
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }

}
